<?php


namespace mpend\modules\actor\models;

use common\base\Model;
use common\helpers\ArrayHelper;
use common\models\actor\Actor;
use common\models\actor\ActorTag;
use common\models\actor\Taglib;
use mpend\modules\actor\controllers\TaglibController;
use Yii;

class TagActorSearch extends Actor
{

    public $tag_id;

    public $pagesize = false;

    public function rules()
    {
        return ArrayHelper::merge(parent::rules(), [
            ['tag_id', 'safe']
        ]);
    }


    public function buildQuery()
    {
        $query = static::find()->alias('t')->active();

        $query->joinWith('actorTags ats');
        $query->andWhere([
            'ats.taglib_id' => $this->tag_id
        ]);
        return $query;
    }

    public function fields()
    {
        return [
            'id',
            'user_id',
            'name',
            'gender',
            'avatar',
            'location',
        ];
    }
}